<template>
  <a-form ref="cronTaskFormRef" :model="cronTaskModel" :rules="cronTaskFormRule" v-bind="layout">
    <a-form-item name="cronTaskNo" :label="t('org.cron-task.cronTaskNo')">
      <a-input-number
        :min="1"
        :max="9999999"
        style="width: 100%"
        v-model:value="cronTaskModel.cronTaskNo"
        :placeholder="t('org.cron-task.formPlhCronTaskNo')"
      />
    </a-form-item>
    <a-form-item name="cronTaskName" :label="t('org.cron-task.cronTaskName')">
      <a-input v-model:value="cronTaskModel.cronTaskName" :placeholder="t('org.cron-task.formPlhCronTaskName')" />
    </a-form-item>
    <a-form-item name="cronExpression" :label="t('org.cron-task.cronExpression')">
      <a-input v-model:value="cronTaskModel.cronExpression" :placeholder="t('org.cron-task.formPlhCronExpression')" />
    </a-form-item>
    <a-form-item name="className" :label="t('org.cron-task.className')">
      <a-input v-model:value="cronTaskModel.className" :placeholder="t('org.cron-task.formPlhClassName')" />
    </a-form-item>
    <a-form-item name="active" :label="t('org.cron-task.active')">
      <a-switch v-model:checked="cronTaskModel.active" />
    </a-form-item>
    <a-form-item name="description" :label="t('org.cron-task.description')">
      <a-textarea
        v-model:value="cronTaskModel.description"
        showCount
        :maxlength="200"
        :placeholder="t('org.cron-task.formPlhdescription')"
      />
    </a-form-item>
  </a-form>
</template>
<script lang='ts'>
import { defineComponent, ref } from 'vue'
import cronTaskApi from '/@/api/org/cron-task'
import { cronTaskFormRule } from '../interface'
import { useModelForm } from '/@/kit/model-kit'
import { useI18n } from 'vue-i18n'
export default defineComponent({
  name: 'CcronTaskForm',
  props: {
    cronTaskId: String,
  },
  setup(props, { emit }) {
    const { t } = useI18n()
    const cronTaskFormRef = ref()
    const cronTaskModel = ref({})

    const { save } = useModelForm(cronTaskFormRef, cronTaskModel, props.cronTaskId, cronTaskApi, {})

    //提交方法
    const onSubmit = () => save().then((res) => emit('submitSuccess', res.data.data))

    const layout = {
      labelCol: { span: 6 },
      wrapperCol: { span: 18 },
    }
    return {
      t,
      cronTaskFormRef,
      cronTaskModel,
      cronTaskFormRule,
      layout,
      onSubmit,
    }
  },
})
</script>
<style lang='less' scoped>
</style>